//
//  FQDLabJoinCountView.m
//  FakeQDaily
//
//  Created by mewxiv on 8/15/16.
//  Copyright © 2016 Xensius. All rights reserved.
//

#import "FQDLabJoinCountView.h"

#import "Masonry.h"

@interface FQDLabJoinCountView ()
// 显示参加人数的label
@property (nonatomic, strong) UILabel *joinNumLabel;

@end

@implementation FQDLabJoinCountView

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        [self prepareUI];
        [self prepareConstraints];
        [self showJoinedNum:1642];
    }
    return self;
}

- (void)prepareUI
{
    _joinNumLabel = [[UILabel alloc] init];
    [_joinNumLabel setFont:FQDDINCondBoldFontWithSize(20.0f)];
    [_joinNumLabel setTextColor:RGB(255, 200, 31)];
    [_joinNumLabel setAdjustsFontSizeToFitWidth:YES];
    [self addSubview:_joinNumLabel];
}

- (void)prepareConstraints
{
    WeakSelf;
    
    [_joinNumLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(weakSelf).offset(6);
        make.centerX.equalTo(weakSelf);
        make.width.equalTo(@30);
        make.height.equalTo(@20);
    }];
}

- (void)showJoinIn
{
    self.joinNumLabel.hidden = YES;
    
    UIImage *image = [UIImage imageNamed:@"Lab_Vote_New"];
    self.image = image;
    
}

- (void)showJoinedNum:(NSInteger)joinNum
{
    self.joinNumLabel.hidden = NO;
    [self.joinNumLabel setText:[NSString stringWithFormat:@"%@", @(joinNum)]];
    
    UIImage *image = [UIImage imageNamed:@"Lab_Vote_Join"];
    self.image = image;
}

@end
